﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SqlSugar;

namespace DADAL
{
    /// <summary>
    /// 界面点位
    ///</summary>
    [SugarTable("c_form_point")]
    public class FormPointModel
    {
        /// <summary>
        /// 备  注:编号
        /// 默认值:
        ///</summary>
        [SugarColumn(ColumnName = "number", IsPrimaryKey = true)]
        public int Number { get; set; }

        /// <summary>
        /// 备  注:名称
        /// 默认值:
        ///</summary>
        [SugarColumn(ColumnName = "name")]
        public string Name { get; set; } = null!;

        /// <summary>
        /// 备  注:设备点位编号
        /// 默认值:
        ///</summary>
        [SugarColumn(ColumnName = "device_point_number")]
        public int DevicePointNumber { get; set; }

        /// <summary>
        /// 备  注:设备点位名称
        /// 默认值:
        ///</summary>
        [SugarColumn(ColumnName = "device_point_name")]
        public string DevicePointName { get; set; } = null!;

        /// <summary>
        /// 备  注:点位类型
        /// 默认值:
        ///</summary>
        [SugarColumn(ColumnName = "point_type")]
        public string PointType { get; set; } = null!;

        /// <summary>
        /// 备  注:界面点位状态
        /// 默认值:
        ///</summary>
        [SugarColumn(ColumnName = "state")]
        public int State { get; set; }

        /// <summary>
        /// 根据点位名判断是否存在
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public static bool RecordExistenceWithName(string name)
        {
            Dictionary<string, Object> where = new Dictionary<string, Object>();
            where["name"] = name;
            List<FormPointModel> list = SqlSugarHelper.Inquireable<FormPointModel>(where);
            if (list.Count > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
    }
}
